Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EQLocalData = exports.WXMSG = undefined;
var $2GameUser = require("GameUser");
var $2ServerConfig = require("ServerConfig");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2Platformconf = require("Platformconf");
var $2MiniBase = require("MiniBase");
var $2BannerMgr = require("BannerMgr");
var $2CustomAdMgr = require("CustomAdMgr");
var $2GridAdMgr = require("GridAdMgr");
var $2InterstitialMgr = require("InterstitialMgr");
var $2ShareMgr = require("ShareMgr");
var $2WX_VideoMgr = require("WX_VideoMgr");
var $2PhoneManager = require("PhoneManager");
var $2InteractiveMgr = require("InteractiveMgr");
var $2AudioManager = require("AudioManager");
var $2UIManager = require("UIManager");
var $2UIPfree = require("UIPfree");
(function (e) {
  e[e.INITFRIENDLIST = 0] = "INITFRIENDLIST";
  e[e.SHOWFIREND = 1] = "SHOWFIREND";
})(exports.WXMSG || (exports.WXMSG = {}));
exports.default = /* */function (_l$default) {
  function _class27() {
    var _this155;
    babel_classCallCheck(this, _class27);
    _this155 = _callSuper(this, _class27);
    _this155.key_maxDistance = "maxDistance";
    _this155.key_countDistance = "countDistance";
    _this155.loadingShow = false;
    _this155.clickTime = 0;
    _this155.getSystemInfo = function () {};
    _this155.active = !!window.wx;
    console.log("微信小游戏");
    return _this155;
  }
  babel_inherits(_class27, _l$default);
  return babel_createClass(_class27, [{
    key: "loadSubpackage",
    value: function loadSubpackage(e, t) {
      if (wx.loadSubpackage) {
        wx.loadSubpackage({
          name: e,
          success(e) {
            console.log("分包加载成功：", JSON.stringify(e));
            t.success && t.success();
          },
          fail(e) {
            console.log("分包加载失败：", JSON.stringify(e));
            t.success && t.success();
          }
        }).onProgressUpdate(function (e) {
          t.onProgressUpdate && t.onProgressUpdate(e);
        });
      } else {
        t.success && t.success();
      }
    }
  }, {
    key: "init",
    value: function init(e) {
      var _this156 = this;
      var t = $2Platformconf.default.eqconfig();
      if (window.wx && window.wx.eqapi) {
        t.onLoginned = function (e) {
          console.log(e, "login res------------------------");
          console.log("++++uid:,", e.uid);
          "" == $2GameUser.default.getInstance().openid && ($2GameUser.default.getInstance().openid = e.openId);
          $2GameUser.default.getInstance().id = e.id;
          $2GameUser.default.getInstance().uid = e.uid;
          _this156.chechLaunchOption(wx.getLaunchOptionsSync());
        };
        window.wx.eqapi.init(t);
      }
      try {
        window.wx.setKeepScreenOn({
          keepScreenOn: true,
          success() {
            console.log("常亮开启");
          }
        });
      } catch (i) {}
      wx.showShareMenu({
        withShareTicket: true,
        menus: ["shareAppMessage", "shareTimeline"]
      });
      var n = wx.getLaunchOptionsSync();
      $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, n);
      wx.onShow(function (e) {
        _this156.chechLaunchOption(e);
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, e);
        console.log("wx.onShow");
        $2AudioManager.AudioManager.getInstance().stopMusic();
        $2AudioManager.AudioManager.getInstance().playBGM("bgm");
      });
      wx.onHide(function (e) {
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONHIDE, e);
      });
      this.updateVersion();
      this.eqInit();
      if ("wx9af5d88f41c1c88c" == t.APPID) {
        console.log("wxsdkinit");
        this.wxsdkinit();
      }
    }
  }, {
    key: "chechLaunchOption",
    value: function chechLaunchOption(e) {
      console.log("验证启动信息:", e);
      console.log("场景值:", e.scene);
      $2EventCenter.default.postEvent("uipfree");
      if (1023 == e.scene) {
        $2GameUser.default.getInstance().setUnlocktili("1", true);
        $2UIManager.UIManager.getInstance().getUI($2UIPfree.default).flash_1();
      } else if (1010 == e.scene) {
        $2GameUser.default.getInstance().setUnlocktili("2", true);
        $2UIManager.UIManager.getInstance().getUI($2UIPfree.default).flash_2();
      } else if (1104 == e.scene) {
        $2GameUser.default.getInstance().setUnlocktili("3", true), $2UIManager.UIManager.getInstance().getUI($2UIPfree.default).flash_3();
      }
      if (e && e.query) {
        var _t76 = e.query.isinvitekey;
        var _n76 = $2GameUser.default.getInstance().openid;
        console.log("myopenid:", _n76);
        console.log("friendid:", _t76);
        if (_t76 && "" != _n76 && _t76 != _n76) {
          console.log("数据托管");
          var _e85 = Date.now();
          $2InteractiveMgr.default.addInvitedRecords(_t76, _n76, _e85, true);
        }
      }
    }
  }, {
    key: "updateVersion",
    value: function updateVersion() {
      if (window.wx && window.wx.getUpdateManager) {
        var _e86 = window.wx.getUpdateManager();
        _e86.onCheckForUpdate(function (t) {
          if (t.hasUpdate) {
            _e86.onUpdateReady(function () {
              window.wx.showModal({
                title: "更新提示",
                content: "新版本已经准备好，是否重启应用？",
                success(t) {
                  if (t.confirm) {
                    console.log("走了该走的地方！");
                    _e86.applyUpdate();
                  } else {
                    console.log("走这里了吗？");
                  }
                }
              });
            });
            _e86.onUpdateFailed(function () {
              window.wx.showModal({
                title: "发现新版本",
                content: "请删除当前小程序，重新搜索打开..."
              });
            });
          }
        });
      }
    }
  }, {
    key: "updateGame",
    value: function updateGame() {
      window.wx && window.wx.getUpdateManager && window.wx.getUpdateManager().applyUpdate();
    }
  }, {
    key: "onUpdateReady",
    value: function onUpdateReady(e) {
      if (window.wx && window.wx.getUpdateManager) {
        var _e87 = window.wx.getUpdateManager();
        _e87.onUpdateReady(function () {
          window.wx.showModal({
            title: "更新提示",
            content: "新版本已经准备好，是否立即使用？",
            success(t) {
              t.confirm && _e87.applyUpdate();
            }
          });
        });
      }
    }
  }, {
    key: "setClipboardData",
    value: function setClipboardData(e) {
      window.wx.setClipboardData && wx.setClipboardData({
        data: e,
        success() {},
        fail(e) {
          console.log("setClipboardData调用失败", e);
        }
      });
    }
  }, {
    key: "eqInit",
    value: function eqInit() {
      wx.eqRegisterHandler && wx.eqRegisterHandler(function (e) {
        console.log("++++++++++++++", e);
        $2ServerConfig.default.getInstance().init(e);
        $2ShareMgr.default.Instance.PreInit([]);
      });
    }
  }, {
    key: "eqIsAuthoried",
    value: function eqIsAuthoried() {
      return wx.eqIsAuthoried();
    }
  }, {
    key: "checkFollowAwemeState",
    value: function checkFollowAwemeState(e) {
      e(true);
    }
  }, {
    key: "openAwemeUserProfile",
    value: function openAwemeUserProfile(e) {
      e(true);
    }
  }, {
    key: "addShortcut",
    value: function addShortcut(e) {
      e(true);
    }
  }, {
    key: "login",
    value: function login(e, t) {
      var n = {};
      if (t) {
        n = {
          type: "text",
          text: "",
          style: {
            left: t.rect.left,
            top: t.rect.top,
            width: t.rect.width,
            height: t.rect.height,
            lineHeight: 40,
            backgroundColor: "",
            color: "",
            textAlign: "center",
            fontSize: 30,
            borderRadius: 4
          },
          success(t) {
            console.log("同意授权", t);
            e(true, t);
          },
          fail(t) {
            console.log("拒绝授权:", t);
            if (1 == t.fromuserbutton) {
              var _t77 = window.wx.eqGetConfig();
              e(false, _t77);
            }
          },
          createbutton(e) {
            console.log("------------------createbutton");
            t.createbutton = e;
          }
        };
        console.log("授权按钮登录");
      }
      wx.eqLogin(n);
    }
  }, {
    key: "checkSession",
    value: function checkSession(e) {
      e(true);
    }
  }, {
    key: "play_AD",
    value: function play_AD(e, t) {
      var n = $2Platformconf.default.Instance.getconfig().WXGame.video[0];
      n = t ? $2Platformconf.default.Instance.getconfig().WXGame.video[t] : $2Platformconf.default.Instance.getconfig().WXGame.video[0];
      if (!n) {
        n = $2Platformconf.default.Instance.getconfig().WXGame.video[0];
      }
      if ("" == n) {
        e && e(true);
      } else {
        $2WX_VideoMgr.WX_VideoMgr.Instance().playvideo(n, e);
      }
    }
  }, {
    key: "share",
    value: function share(e, t) {
      $2ShareMgr.default.Instance.share(e, t);
    }
  }, {
    key: "appClick",
    value: function appClick(e, t) {
      1 == wx.clickedApp(t.appId) && (t = $2ServerConfig.default.getInstance().getNewApp() || t);
      t.extraData = {
        launch: $2PhoneManager.default.getInstance().launch
      };
      t.success = function (n) {
        if (n) {
          console.log("跳转成功回调" + n);
          wx.addclickApp(t.appId);
          e(true);
        }
      };
      t.fail = function (t) {
        console.log("跳转失败回调" + t);
        e(false);
      };
      if (0 == this.clickTime) {
        this.clickTime++;
        var _n77 = $2ServerConfig.default.getInstance().getNewApp(t.appId);
        _n77 && this.appClick(e, _n77);
      }
      wx.eqTouch(t);
    }
  }, {
    key: "showLoading",
    value: function showLoading(e) {
      var _this157 = this;
      if (0 == this.loadingShow) {
        this.loadingShow = true;
        window.wx.showLoading({
          title: "请求中，请稍后...",
          success(e) {
            console.log("".concat(e));
          },
          fail() {
            _this157.loadingShow = false;
            console.log("showLoading调用失败");
          }
        });
      }
    }
  }, {
    key: "hideLoading",
    value: function hideLoading() {
      var _this158 = this;
      1 == this.loadingShow && window.wx.hideLoading({
        success() {
          _this158.loadingShow = false;
          console.log("hideLoading调用成功");
        },
        fail() {
          console.log("hideLoading调用失败");
        }
      });
    }
  }, {
    key: "sendEQEvent",
    value: function sendEQEvent(e, t, n) {
      wx.eqSendEvent(e, t, n);
    }
  }, {
    key: "vibrate",
    value: function vibrate() {
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
      if (e) {
        wx.vibrateShort();
      } else {
        wx.vibrateLong();
      }
    }
  }, {
    key: "createImage",
    value: function createImage(e, t) {
      var n = wx.createImage();
      n.onload = function () {
        t(n);
      };
      n.src = e;
    }
  }, {
    key: "getTargetId",
    value: function getTargetId() {
      var e = wx.getLaunchOptionsSync();
      var t = e.query.supportId;
      var n = e.query.targetID;
      e.query.level;
      console.log(">>>>>>>>>>>>>>>>>:" + JSON.stringify(e));
      console.log(" supportId: " + t);
      console.log(" shareId: " + n);
      e.scene;
    }
  }, {
    key: "onPostMessage",
    value: function onPostMessage(e) {
      console.log("onPostMessage==", e);
      wx.getOpenDataContext().postMessage(e);
    }
  }, {
    key: "uploadCloudStorage",
    value: function uploadCloudStorage(e, t) {
      if (wx) {
        console.log("上传成绩", e, t);
        window.wx.setUserCloudStorage({
          KVDataList: [{
            key: e,
            value: t.toString()
          }],
          success(e) {
            console.log("uploadScore success:res=>", e);
          },
          fail(e) {
            console.log("uploadScore fail:res=>", e);
          }
        });
      }
    }
  }, {
    key: "loginCallBack",
    value: function loginCallBack() {
      this.getTargetId();
    }
  }, {
    key: "HasClicked",
    value: function HasClicked(e) {
      var t = false;
      for (var _n78 = 0; _n78 < this._eqLocalData.clickedAppList.length; _n78++) {
        if (e == this._eqLocalData.clickedAppList[_n78]) {
          t = true;
          break;
        }
      }
      return t;
    }
  }, {
    key: "request",
    value: function request(e, t, n) {
      wx.request({
        url: e,
        method: "POST",
        data: t,
        success(e) {
          n && n(e);
        },
        fail(e) {
          n && n(e);
        }
      });
    }
  }, {
    key: "bannerDestroy",
    value: function bannerDestroy(e) {
      $2BannerMgr.default.Instance.Destroy(this.getbannerid(e));
    }
  }, {
    key: "bannerCreate",
    value: function bannerCreate(e, t) {
      $2BannerMgr.default.Instance.Create(this.getbannerid(e), t);
    }
  }, {
    key: "bannerrefreshAD",
    value: function bannerrefreshAD(e, t) {
      console.log("bannerrefreshAD");
      $2BannerMgr.default.Instance.refreshAD(this.getbannerid(e), t);
    }
  }, {
    key: "bannerShow",
    value: function bannerShow(e, t) {
      console.log("bannerShow:", e);
      $2BannerMgr.default.Instance.Show(this.getbannerid(e), t);
    }
  }, {
    key: "bannerHide",
    value: function bannerHide(e) {
      $2BannerMgr.default.Instance.Hide(this.getbannerid(e));
    }
  }, {
    key: "bannertempHide",
    value: function bannertempHide() {
      $2BannerMgr.default.Instance.tempHide();
    }
  }, {
    key: "bannertempShow",
    value: function bannertempShow() {
      $2BannerMgr.default.Instance.tempShow();
    }
  }, {
    key: "getbannerid",
    value: function getbannerid(e) {
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.banner[e] : $2Platformconf.default.Instance.getconfig().WXGame.banner[0];
      console.log("getbannerid:", t);
      return t;
    }
  }, {
    key: "loadGridAd",
    value: function loadGridAd(e, t, n) {
      var o = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "black";
      var i = "";
      i = e ? $2Platformconf.default.Instance.getconfig().WXGame.GridAd[e] : $2Platformconf.default.Instance.getconfig().WXGame.GridAd[0];
      $2GridAdMgr.default.Instance.Create(i, t, n, o);
    }
  }, {
    key: "showGridAd",
    value: function showGridAd(e, t, n) {
      var o = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "black";
      var i = "";
      i = e ? $2Platformconf.default.Instance.getconfig().WXGame.GridAd[e] : $2Platformconf.default.Instance.getconfig().WXGame.GridAd[0];
      $2GridAdMgr.default.Instance.Show(i, t, n, o);
    }
  }, {
    key: "hideGridAd",
    value: function hideGridAd(e) {
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.GridAd[e] : $2Platformconf.default.Instance.getconfig().WXGame.GridAd[0];
      $2GridAdMgr.default.Instance.Hide(t);
    }
  }, {
    key: "destroyGridAd",
    value: function destroyGridAd(e) {
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.GridAd[e] : $2Platformconf.default.Instance.getconfig().WXGame.GridAd[0];
      $2GridAdMgr.default.Instance.Destroy(t);
    }
  }, {
    key: "loadCustomAd",
    value: function loadCustomAd(e, t) {
      console.log('初始化原生广告！！！')
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
      var o = "";
      o = e ? $2Platformconf.default.Instance.getconfig().WXGame.Custom[e] : $2Platformconf.default.Instance.getconfig().WXGame.Custom[0];
      $2CustomAdMgr.default.Instance.Create(o, t, n);
    }
  }, {
    key: "showCustomAd",
    value: function showCustomAd(e, t) {
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
      console.log("showCustomAd id:", e);
      var o = "";
      o = e ? $2Platformconf.default.Instance.getconfig().WXGame.Custom[e] : $2Platformconf.default.Instance.getconfig().WXGame.Custom[0];
      $2CustomAdMgr.default.Instance.Show(o, t, n);
    }
  }, {
    key: "hideCustomAd",
    value: function hideCustomAd(e) {
      console.log("hideCustomAd id:", e);
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.Custom[e] : $2Platformconf.default.Instance.getconfig().WXGame.Custom[0];
      $2CustomAdMgr.default.Instance.Hide(t);
    }
  }, {
    key: "destroyCustomAd",
    value: function destroyCustomAd(e) {
      var t = "";
      console.log("destroyCustomAd id:", e);
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.Custom[e] : $2Platformconf.default.Instance.getconfig().WXGame.Custom[0];
      $2CustomAdMgr.default.Instance.Destroy(t);
    }
  }, {
    key: "interstitialShow",
    value: function interstitialShow(e) {
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().WXGame.Interstitial[e] : $2Platformconf.default.Instance.getconfig().WXGame.Interstitial[0];
      $2InterstitialMgr.default.Instance.show(t);
    }
  }, {
    key: "shareAppMessage",
    value: function shareAppMessage(e, t) {
      $2ShareMgr.default.Instance.shareAppMessage(e, t);
    }
  }, {
    key: "shareDiyMap",
    value: function shareDiyMap(e, t) {
      var n = {
        _nickname: e.nickname,
        mapid: e.mapid,
        mapUrl: e.mapUrl,
        share_index: e.shareindex
      };
      $2ShareMgr.default.Instance.shareAppMessage(t, n);
      console.log("shareDiyMap:", n);
    }
  }, {
    key: "wxsdkinit",
    value: function wxsdkinit() {
      var e = window.wxsdk;
      e.init({
        version: "1.0.0",
        appid: "736",
        secret: "scb3elecbz24ozt39bs2u24bps3xvz26",
        share: {
          title: "你能过得了这一关吗？",
          image: "https://game-oss.smallshark.cn/game/20221130/19105915183d87.jpg?imageslim"
        }
      });
      e.onInit(function (e) {
        console.log("wxsdkonInit", e);
      });
      e.login();
      e.onLoginComplete(function (t) {
        console.log("onLoginCallback", t);
        if ("success" == e.getLoginStatus()) {
          console.log("login success!");
        } else {
          e.getLoginStatus();
        }
      });
    }
  }]);
}($2MiniBase.default);
exports.EQLocalData = /* */function () {
  function _class28() {
    babel_classCallCheck(this, _class28);
    this.clickedAppList = [];
  }
  return babel_createClass(_class28);
}();